﻿@model Poco.Restaurant

@{
    ViewBag.Title = "Editer Restaurant";
    
     //prepare la dropdownlist des categories
    List<SelectListItem> managers = new List<SelectListItem>();

    if (ViewBag.managers != null)
    {
        foreach (Poco.Manager m in ViewBag.managers)
        {
            managers.Add(new SelectListItem() { Text = m.Nom, Value = m.Id.ToString() });
        }
    }
    else
    {
        managers.Add(new SelectListItem(){Text = "Aucun Manager", Value = "0"}); 
    }
}

<h2>Editer Restaurant</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Restaurant</legend>

        @Html.HiddenFor(model => model.Id)

        <div class="editor-label">
            @Html.LabelFor(model => model.Nom)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Nom)
            @Html.ValidationMessageFor(model => model.Nom)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Description)
            @Html.ValidationMessageFor(model => model.Description)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Adresse)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Adresse)
            @Html.ValidationMessageFor(model => model.Adresse)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Capacite)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Capacite)
            @Html.ValidationMessageFor(model => model.Capacite)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Telephone)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Telephone)
            @Html.ValidationMessageFor(model => model.Telephone)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Email)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Email)
            @Html.ValidationMessageFor(model => model.Email)
        </div>

        <div class="editor-field">
            @Html.Label("Manager :")
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.Manager.Nom, managers)
        </div>

        <p>
            <input type="submit" value="Enregistrer" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Retour à la liste", "Restaurants")
</div>
